<template>
	<view class="myInviteTeachers-page">
		<head-box></head-box>
    <view class="tab-botton">
      <cl-group :list="list"></cl-group>
      <u-loadmore :status="status" :icon-type="iconType" @loadmore="loadmore" />
		</view>

		<tabs-box></tabs-box>
	</view>
</template>

<script>
	import {gpUserGpapplyList,gpGpinfo} from '@/api/group'
  import clGroup from '@/components/clGroup'
  import {getgpinfoapplyStatus} from '@/common/type'
	export default {
    components:{
      clGroup
    },
		data() {
			return {
        pageNo:1,//第几页
        pageSize:10,//每页条数
        search:'',//搜索相关内容
        status: 'loadmore', //加载的状态
        iconType: 'flower', //加载图标样式
        isLoading: false, //是否要加载数据
        pList:[],//其他数据
				list:[],//必要数据
			};
		},
		onLoad() {
		  this.getList()
		},
    onShow(){
      // #ifdef H5
      console.log('分享')
      this.$wxSetShare()
      // #endif
    },
		methods:{
      loadmore(){
        this.pageNo++
        this.getList()
      },
      //审核状态
      getgpinfoapplyStatus(s){
        return getgpinfoapplyStatus(s)
      },
      //我的群团列表
			getList() {
				var that = this
        if (this.isLoading) {
          return
        }
        this.isLoading = true
        this.status = 'loading'
				const params = {'usergpinfoapplyStatus':'4',pageNo:this.pageNo,pageSize:this.pageSize}

        gpUserGpapplyList(params).then(res => {
          const {code,result:{records:list,total}}= res
          if(code===200){
            this.isLoading = false
            uni.hideLoading()
            if (!list.length) {
              this.status = 'nomore'
            }else {
              this.status = 'loadmore'
              this.pList =[... this.pList,...list]
              if (this.pList.length >= total) {
                this.status = 'nomore'
              }
              list.map(item=>{
                gpGpinfo(item.gpinfoId).then(res => {
                  if(res.success) {
                    that.list.push({'usergpinfoapplyStatus':usergpinfoapplyStatus,'gpinfoName':res.result.gpinfoName,'gpinfoLogo':res.result.gpinfoLogo,'gpinfoIntroduce':res.result.gpinfoIntroduce,'createTime':res.result.createTime})
                  }
                });
              })
            }
          }
				});
			},
		},
    //加载到底部进行请求新的数据
    onReachBottom() {
      if (this.status === 'loadmore') {
        this.loadmore()
      }
    },
	}
</script>

